<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property string $title 
 * @property int $space_id 
 * @property string $file 
 * @property string $url 
 * @property int $listorder 
 * @property int $status 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property string $deleted_at 
 */
class AdDatum extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'ad_data';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'title',
        'file',
        'space_id',
        'url',
        'listorder',
        'status'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'space_id' => 'integer', 'listorder' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function getFileAttribute($field)
    {
        return $this->attributes[$field] = $field?config('common.image_prefix').$field:null;
    }
    public function setFileAttribute($value)
    {
        return $this->attributes['file'] = str_replace(config('common.image_prefix'),'',$value);
    }
}